package dissertation.common.utils.applicationxml.decorator;

/**
 * Application xml decorator for EJB 3.0
 */
public class ApplicationXMLDecoratorV30 implements IApplicationXMLDecorator {
    private static final String ROOT_START = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<application xmlns=\"http://java.sun.com/xml/ns/javaee\"" +
            "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"5\"" +
            "xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd\">";
    private static final String ROOT_END = "</application>";
    private static final String MODULE_START = "<module><ejb>";
    private static final String MODULE_END = "</ejb></module>";

    /**
     * Decorates jarName with module tag
     * @param jarName - the jar name
     * @return - the result decoration
     */
    @Override
    public String decorateWithModuleTag(String jarName) {
        return MODULE_START + jarName + MODULE_END;
    }

    /**
     * Decorates the content with the application xml root tag
     * @param content - the input content
     * @return - the result decoration
     */
    @Override
    public String decorateWithRootTag(String content) {
        return ROOT_START + content + ROOT_END;
    }
}
